#@layout("平台RSS") #define selectform() #end #define main()

#end 
#define js()
	<!--模板-->
	<script type="text/html" id="tpl">
			<blockquote class="layui-elem-quote">
				{{ d.userInfo.realname1}}的个人信息
				<a href="javascript:;" class="layui-btn layui-btn" id="edit" style="margin-left: 25px;">
					<i class="layui-icon">&#xe608;</i> 修改
				</a>
			</blockquote>
			<fieldset class="layui-elem-field">
				<legend>个人信息</legend>
				<input type="hidden" id="id" value ="{{ d.userInfo.id}}">
				<div id="info" style=" width: 60%; margin: 0 auto;">
			<table class="layui-table" lay-even="" lay-skin="line">
  			<colgroup>
   				<col width="50">
    			<col width="100">
				<col width="250">
    			<col>
 			 </colgroup>
  			 <thead>
 			 </thead>
  			 <tbody>
	 			<tr>
      			<td>姓名  	<a href="javascript:;" data-name='{{ JSON.stringify(d.userInfo) }}' data-opt="edit" class="layui-hide"></a></td>
     			 <td>{{ d.userInfo.realname1}}</td>
	 			 <td rowspan = 4 ><img src="{{  d.userInfo.photo}}" class="layui-circle" style="width: 15em; height: 15em;"></td>
   				</tr>
    			<tr>
      				<td>email</td>
      				<td>{{  d.userInfo.email}}</td>
    			</tr>
				<tr>
      				<td>电话</td>
      				<td>{{  d.userInfo.phone}}</td>
    			</tr>
				<tr>
      				<td>创建时间</td>
      				<td>{{  d.userInfo.ctime}}</td>
    			</tr>
 			 </tbody>
			</table> 
			</div>
			</fieldset>
		</script>
	<script>
			layui.use(['laytpl','form','layer','upload'], function() {
				var $ = layui.jquery,
				layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
				layer = layui.layer, //获取当前窗口的layer对象
				form = layui.form(),
				laytpl = layui.laytpl;

				//第三步：渲染模版
		
				var getTpl = tpl.innerHTML;
		        $.ajax({
					type: 'post',
					url:  'user/user',
					async: false,
					data: '',
					dataType: 'json',
					success: function(result, status, xhr) {
						if(result.isOk){
							laytpl(getTpl).render(result, function(html){
								  $(".admin-main").html( html);
								});
							}
						else{layer.msg(result.msg);}
						}
				});

				$('#edit').on('click', function(){

					loadUserform($('a[data-opt=edit]').data('name'));
					});

				//********************************
	             var loadUserform = function (item){
					$.get('htmlTemp/editUser.html', null, function(form) {
							addBoxIndex = layer.open({
								type: 1,
								title: '修改用信息',
								content: form,
								btn: ['保存', '取消'],
								shade: false,
								offset: ['100px', '30%'],
								area: ['600px', '400px'],
								zIndex: 19950924,
								yes: function(index) {
									//触发表单的提交事件
									//设置提交地址
									$('form.layui-form').find('button[lay-filter=edit]').click();
								},
								success: function(layero, index) {
									
									//给表单赋值
									/**********/
									$("input[name='id']").val(item.id);
									$("input[name='realname1']").val(item.realname1);
									$("input[name='email']").val(item.email);
									$("input[name='phone']").val(item.phone);
									$("#LAY_demo_upload").attr('src', item.photo);
									$("#photo").val(item.photo)
									
									
									/************/	
									var form = layui.form();
									form.render();
									layui.upload({
									    url: 'user/upload'
									    ,elem: '#test' //指定原始元素，默认直接查找class="layui-upload-file"
									    ,method: 'post' //上传接口的http类型
									    ,success: function(res){
										    if(res.isSuccess){
										  $('#photo').val(res.url);   
									      LAY_demo_upload.src = res.url;
										    }
										}
									 });
									//部门级联操作
									form.on('select(depart)',function(data){
										o_data.url = 'organiz/findbypid'
										o_data.pid = data.value;
										addorganiz(o_data, b);
										form.render("select");
									});
									
									form.on('submit(edit)', function(data) {
									   delete data.field.file;
										$.ajax({
											type: 'post',
											url:  'user/upd',
											data: data.field,
											dataType: 'json',
											success: function(result, status, xhr) {
												if(result.isOk){
													layerTips.msg(result.msg);
													location.reload(); //刷新
													}
												}
										});
										
										return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。									
									});
									//console.log(layero, index);
								},
								end: function() {
									addBoxIndex = -1;
								}
							});
						});
					}
	         	
			
			});
		</script>
#end
